#include <stdio.h>

int main(int argc, char *argv[])
{

    int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    int year = 0, month = 0, day = 0;

    scanf("%d %d %d", &year, &month, &day);

    if ((year % 4 == 0 && year % 400 != 0) || (year % 400 == 0))
    {
        days[1] = 29;
    }

    int sum = 0;

    if (month == 1)
    {
        printf("%d", day);
    }
    else
    {
        for (size_t i = 0; i < month-1; i++)
        {
            sum += days[i];
        }
        sum += day;
        printf("%d", sum);
    }

    return 0;
}